class Admin::DepartmentsController < AdminController

  def new
    @department = Department.new
  end

  def create
    @department = Department.new params[:department]
    success = @department && @department.save
    flash[:notice] = success && @department.errors.empty? ? t(:department_created) : t(:error_department_creation)
    redirect_to :back
  end
  
  def update
    object
    success = @department.update_attributes(params[:department])
    flash[:notice] = success && @department.errors.empty? ? t(:department_updated) : t(:error_department_update)
    redirect_to :back
  end

  destroy.wants.html { redirect_to :back }

  private

  def collection
    @departments ||= Department.all
  end

  def object
    @department ||= Department.find(params[:id])
  end

  def model_name
    'department'
  end

end
